package cn.stacey.day10;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.junit.Test;



public class DemoFileCopy {
	@Test
	public void testFileCopy() {
//		File source=new File("‪E:\\day\\01. git流程复习.mp4");
		File source=new File("‪‪E:\\day\\01. git流程复习.mp4");
		File target=new File("‪‪test.map4");
		try(
				
				FileInputStream fi=new FileInputStream(source);
				FileOutputStream fo=new FileOutputStream(target);
				) {
			
			byte[] contents=new byte[1024];
//			int count=0;
//			while((count=fi.read(contents))!=-1) {
//				fo.write(contents, 0, count);
//			}
			int count=0;
		while(true) {
			count=fi.read(contents);
			if(count==-1) {
				
				break;
			}
			fo.write(contents, 0, count);
		}
		
//			System.out.println(count);
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}

}
